<template>
  <div class="form1_container">
    <!--      header区域-->
    <Header_></Header_>
    <!--表单-->
    <div class="form-content">
      <el-form :model="form1Data" :rules="rules" ref="form1" label-width="80px" class="demo-ruleForm" :status-icon="statusIcon" label-position="top">
        <div class="wrap">
          <div class="left">
            <!--            左边表单-->
            <Left :form1Data="form1Data"></Left>
          </div>
          <!--          右边头像-->
          <div class="right">
            <Right></Right>
          </div>
        </div>
        <!--        出生年月 && 工作经验 && 求职状态表单-->
        <ContentInput :form1Data="form1Data"></ContentInput>
        <el-form-item class="btn-container">
          <el-button @click="resetForm('form1')">重置</el-button>
          <el-button type="primary" @click="submitForm('form1')">下一步</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import Header_ from './component/Header_'
import Left from './component/Left'
import Right from './component/Right'
import ContentInput from './component/Content'

export default {
  name: 'index',
  components: {ContentInput, Right, Left, Header_},
  data() {
    return {
      statusIcon: true,
      form1Data: {
        name: '',
        sex: '',
        bron: '',
        work_experience: '',
        job_status: ''
      },
      rules: {
        name: [
          {required: true, message: '请输入您的姓名', trigger: 'blur'},
          {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'}
        ],
        sex: [
          {required: true, message: '请输入您的性别', trigger: 'blur'}
        ]
      }
    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
          this.$router.push('/form2')
        } else {
          console.log('error submit!!')
          return false
        }
      })
      console.log(this.form1Data)
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style lang="scss" scoped>
.form1_container {
  box-sizing: border-box;
  margin: 0 auto;
  width: 500px;
  overflow: auto;
  background-color: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 12px;
  margin-top: 20px;

  .form-content {
    padding: 0 22px;

    .wrap {
      display: flex;

      .left {
        width: 60%;
      }

      .right {
        flex: 1;
      }
    }

    .btn-container {
      display: flex;
      justify-content: flex-end;
    }
  }
}

</style>
